import Vue from 'vue'
import Router from 'vue-router';
import sortRouterList from './sort-router'

Vue.use(Router)

/**
 * 重写路由的push方法
 */
// const routerPush = Router.prototype.push
// Router.prototype.push = function push(location) {
//     return routerPush.call(this, location).catch(error => error)
// }

const login = r => require.ensure([], () => r(require('@/views/login')), 'login');
// const list = store.state.routerSort || []

export const constantRouterMap = [{
  path: '/login',
  component: login,
  hidden: true
},
  ...sortRouterList
]

/* 初始路由 */
export default new VueRouter({
  // mode: 'history', //后端支持可开
  scrollBehavior(to, from, savedPosition) {
    return {
      x: 0,
      y: 0
    }
  },
  routes: constantRouterMap
})

// export const asyncRouterMap = []



// export const allRoutes = []